package org.dolphin.entity.misc;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import org.springframework.util.ObjectUtils;

@Entity
@Table(name = "XS_USER_LOCALE", uniqueConstraints = {
    @UniqueConstraint(columnNames = {"LANGUAGE", "COUNTRY", "VARIANT"}, name = "UQ_XS_USER_LOCALE_COUNTRY_VARIANT"),
    @UniqueConstraint(columnNames = {"DESCRIPTION"}, name = "UQ_XS_USER_LOCALE_DESCRIPTION")})
public class UserLocale implements Serializable {
  private static final long serialVersionUID = 8865121362146268271L;
  private String id;
  private String language;
  private String country;
  private String variant;
  private String description;

  @Override
  public boolean equals(Object obj) {
    if (obj == this) {
      return true;
    } else if (obj instanceof UserLocale) {
      UserLocale oth = (UserLocale) obj;
      return ObjectUtils.nullSafeEquals(getId(), oth.getId());
    }
    return false;
  }

  @Column(name = "COUNTRY", length = 10)
  public String getCountry() {
    return country;
  }

  @Column(name = "DESCRIPTION", nullable = false, length = 100)
  public String getDescription() {
    return description;
  }

  @Id
  @Column(name = "ID", nullable = false)
  public String getId() {
    return id;
  }

  @Column(name = "LANGUAGE", nullable = false, length = 10)
  public String getLanguage() {
    return language;
  }

  @Column(name = "VARIANT", length = 10)
  public String getVariant() {
    return variant;
  }

  @Override
  public int hashCode() {
    int hash = ObjectUtils.nullSafeHashCode(getId());
    return hash;
  }

  public void setCountry(String country) {
    this.country = country;
  }

  public void setDescription(String description) {
    this.description = description;
  }

  public void setId(String id) {
    this.id = id;
  }

  public void setLanguage(String language) {
    this.language = language;
  }

  public void setVariant(String variant) {
    this.variant = variant;
  }
}
